package org.gruposp2p.proyectokarma.gwt.client.event;

import org.gruposp2p.proyectokarma.gwt.client.MainEntryPoint;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

public class TagEvent extends GwtEvent {
	
    private static final GwtEvent.Type TYPE = new GwtEvent.Type();

    
    public enum Action {GET_DOCUMENTS, GET_COMMENTS}

    public Action eventAction;
    public String tagName;


    @Override
    public Type getAssociatedType() { return TYPE;}
    public static GwtEvent.Type getType() { return TYPE;}

    @Override
    protected void dispatch(EventHandler handler) {
    	((TagEvent.Handler)handler).onTagChanged(this);
    }

    public TagEvent (Action eventAction, String tagName) {
        this.eventAction = eventAction;
        this.tagName = tagName;
        MainEntryPoint.INSTANCE.sessionData.setSelectedTag(tagName);
    }
    
    /**
     * Implemented by handlers of this type of event.
     */
    public interface Handler extends EventHandler {
    	void onTagChanged(TagEvent event);
    }

}